<?php

require_once "class/Load.class.php";
require_once "class/Sql.class.php";
require_once "class/Inputs.class.php";
require_once "class/Config.class.php";
require_once "class/StatusRoster.class.php";
require_once "class/SessionRoster.class.php";
require_once "class/Localization.class.php";

// For loading information in footer
Load::GetInstance();

// For user session
SessionRoster::GetInstance();

if ( Inputs::GetInstance()->HasPostData('submit') ) {
	if ( Sql::GetInstance()->Query("ALTER TABLE `cp_items` DROP `TooltipLeft`, DROP `TooltipRight`, DROP `TooltipOverlib`;") != true ) {
		StatusRoster::GetInstance()->AddError( Localization::GetInstance()->Get('could not update roster: %s', Sql::GetInstance()->GetLastError()) );
	}
	
	if ( Sql::GetInstance()->Query("ALTER TABLE `cp_spells` DROP `TooltipLeft`, DROP `TooltipRight`, DROP `TooltipOverlib`;") != true ) {
		StatusRoster::GetInstance()->AddError( Localization::GetInstance()->Get('could not update roster: %s', Sql::GetInstance()->GetLastError()) );
	}
	
	if (!StatusRoster::GetInstance()->HasError()) {
		StatusRoster::GetInstance()->AddSuccess( Localization::GetInstance()->Get('roster successfully updated') );
		StatusRoster::GetInstance()->AddNote( Localization::GetInstance()->Get('you can now delete the update script and go back on the %s main page', "index.php") );
	} else {
		StatusRoster::GetInstance()->AddNote( Localization::GetInstance()->Get('your roster is maybe already up to date') );
	}
	
	SessionRoster::GetInstance()->SaveStatus(StatusRoster::GetInstance());
	SessionRoster::GetInstance()->Redirect('update-347.php');
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<title>LZRoster<?php echo Config::GetInstance()->HasRosterTitle() ?  " - ".Config::GetInstance()->GetRosterTitle() : null; ?></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" media="screen" type="text/css" href="styles/_.css" />
	</head>
	<body>
		
		<?php require_once "inc/head.php"; ?>
		
		<h2><?php echo Localization::GetInstance()->Get('update'); ?></h2>
		
		<?php
		if (SessionRoster::GetInstance()->HasStatus())
		{
		?>
			
			<p>
				<?php echo Localization::GetInstance()->Get('this page produced some messages. please refer to the following lines'); ?>
			</p>
			
			<?php echo SessionRoster::GetInstance()->GetStatus()->GetStack_InList(); ?>
			
			<p>
				<?php echo Localization::GetInstance()->Get('you can refresh the page %s and try again', "update-347.php"); ?>
			</p>
			
		<?php
		}
		else
		{
		?>
		
		<form action="update-347.php" method="post">
		<p style="text-align: center;">
			<?php echo Localization::GetInstance()->Get('in order to update your roster, simply click on the button below'); ?><br />
			<input type="submit" name="submit" value="<?php echo Localization::GetInstance()->Get('update'); ?>" />
		</p>
		</form>
		
		<?php
		}
		?>
		
		<?php require_once "inc/foot.php"; ?>
		
	</body>
</html>